<template>
	<view class="me">
		<my-header bgColor="bg-gradual-blue" :isBack="true">
			<block slot="backText">返回</block>
			<block slot="content">驾考宝典</block>
		</my-header>
        <view class="user_info row">
            <image class="avatar" :src="user.avatarUrl" mode="" />
            <view class="info">
                <view class="name">{{user.nickName}}</view>
				<!-- <vieew class="sex row">
					性别：
					<view v-if="user.gender==1" class="cuIcon-male  man"></view>
					<view v-if="user.gender==1" class="cuIcon-female woman"></view>
					<view v-if="user.gender==2" class="cuIcon-female woman"></view>
				</vieew> -->
                <view class="driver_type row">驾照类型/科目
                    <view style="margin-left:auto;">{{driver.driveType}}/{{driver.examType==1?"科一":driver.subject==4?"科四":"未设置科目"}}</view>
                </view>
            </view>
        </view>
       
        <view class="list">
			<view class="item row" v-for="(item,index) in list" :key="index" @click="go(item)">
				<image class="icon" :src="item.icon"/>
				{{item.name}}
				<view class="cuIcon-right right"></view>
			</view>
		</view>
	</view>
</template>

<script>
	
	export default {
		data() {
			return {
                user:{},
                driver:{},
				list:[
					{
                    // "icon"=>$url."zhifu-yue.png",
						icon:"/static/icon/link.png",
						name:"驾考练习",
						link:"./examList?cur=4&subject=1&model=c1"
					},
					{
						icon:"/static/icon/tag.png",
						name:"驾考模拟",
						link:"./exam?type=practice"
					},
					{
						icon:"/static/icon/house.png",
						name:"设置",
						link:"./setting"
                    },
					{
						icon:"/static/icon/about.png",
						name:"关于我们",
						link:"/tools/about/index?module=house"
					},
                ],
                driverType:[
                    "c1","c2","a1","a2","b1","b2"
                ],
                examType:[
                    1,3
                ]
			}
		}, 
		onLoad(){
            this.get_userInfo()
            uni.navigateTo({
                 url: this.list[0].link
            });
        },
        onShow(){
            console.log(123);
            this.initData()
        },
		methods: {
			async initData(){
				const res=await uni.$request({
                },"api/driverExam/getUserInfo")
				this.driver=res.data.driverInfo
				uni.setStorageSync('driverInfo', res.data.driverInfo)
                this.is_driveInfo()

			},
			async is_driveInfo(){
				if (!this.driver.examType) {
				const res=await	uni.$err("您还没有设置驾照类型和科目，请前往设置")
					if (res.code==200) {
						uni.navigateTo({
							url: './setting'
						});
					}
					
                }
			},
            async get_userInfo(){
				const res=await uni.$request({
                },"api/user/get_userInfo")
                this.user=res.data
                
            },
            
			go(item){
				if (item.type=="copy") {
					let openid= uni.getStorageSync('openid')
					uni.$copy(item.link+"?"+openid)
				}else{
					uni.navigateTo({
						url:item.link,
						success:(res)=>{
							console.log(res);
						},
						fail:(err)=>{
							console.log(err);
						}
					});
				}
				
            },
            
			
			
		}
	}
</script>

<style lang="scss">
	// @import "../../pages/house/mePage/index";
	@import "../main";
</style>